
package com.hexinfo.dmpro.sparing.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hexinfo.dmpro.common.utils.CommonConstants;
import com.hexinfo.dmpro.sparing.model.TimeFieldMatching;
import com.hexinfo.dmpro.sparing.dao.TimeFieldMatchingMapper;
import com.hexinfo.dmpro.sparing.service.TimeFieldMatchingService;
import org.springframework.stereotype.Service;

/**
 * 时间字段匹配表
 *
 * @author yemw
 * @date 2023-09-08 18:07:25
 */
@Service
public class TimeFieldMatchingServiceImpl extends ServiceImpl<TimeFieldMatchingMapper, TimeFieldMatching> implements TimeFieldMatchingService {

    @Override
    public Page queryList(Page page, TimeFieldMatching timeFieldMatching) {
        LambdaQueryWrapper<TimeFieldMatching> wrapper = Wrappers.lambdaQuery();
        wrapper.like(StrUtil.isNotBlank(timeFieldMatching.getTimeFieldKay()),TimeFieldMatching::getTimeFieldKay,timeFieldMatching.getTimeFieldKay())
                .eq(TimeFieldMatching::getDel,CommonConstants.STATUS_NORMAL);
        Page returnPage = this.baseMapper.selectPage(page, wrapper);
        return returnPage;
    }

    @Override
    public TimeFieldMatching queryList(String timeFieldKay) {
        LambdaQueryWrapper<TimeFieldMatching> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(TimeFieldMatching::getDel,CommonConstants.STATUS_NORMAL)
                .eq(TimeFieldMatching::getTimeFieldKay,timeFieldKay);
        return this.baseMapper.selectOne(wrapper);
    }
}
